package com.hdu.seckilldemo.config;

import org.springframework.amqp.core.Binding;
import org.springframework.amqp.core.BindingBuilder;
import org.springframework.amqp.core.Queue;
import org.springframework.amqp.core.TopicExchange;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

//RabbitMQ配置类_ topic
@Configuration
public class RabbitMQConfigTopic {
    private static final String EXCHANGE = "seckillExchange";
    private static final String QUEUE = "seckillQueue";

    @Bean
    public Queue seckill_Order_Queue(){
        return new Queue(QUEUE);
    }
    @Bean
    public TopicExchange topicExchange(){
        return  new TopicExchange(EXCHANGE);
    }
    @Bean
    public Binding binding_topic(){
        return BindingBuilder.bind(seckill_Order_Queue()).to(topicExchange()).with("seckill.#");
    }
/*    private static final String QUEUE_TOPIC01 = "queue_topic01";
    private static final String QUEUE_TOPIC02 = "queue_topic02";
    private static final String EXCHANGE_TOPIC = "topicExchange";
    private static final String ROUTINGKEY03 = "#.queue.#";
    private static final String ROUTINGKEY04 = "*.queue.*";

    @Bean
    public Queue queue_topic01(){
        return new Queue(QUEUE_TOPIC01);
    }

    @Bean
    public Queue queue_topic02(){
        return new Queue(QUEUE_TOPIC02);
    }

    @Bean
    public TopicExchange topicExchange(){
        return new TopicExchange(EXCHANGE_TOPIC);
    }
    @Bean
    public Binding binding_topic01(){
        return BindingBuilder.bind(queue_topic01()).to(topicExchange()).with(ROUTINGKEY03);
    }

    @Bean
    public Binding binding_topic02(){
        return BindingBuilder.bind(queue_topic02()).to(topicExchange()).with(ROUTINGKEY04);
    }*/
}
